{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import re\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "WORK_DIR = r'G:\\01Download\\temp\\lunyu_20191012'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "CHAPTER_FILES = [\n",
    "\t[\"學而\", \"01 Xue Er.txt\"],\n",
    "\t[\"為政\", \"02 Wei Zheng.txt\"],\n",
    "\t[\"八佾\", \"03 Ba Yi.txt\"],\n",
    "\t[\"里仁\", \"04 Li Ren.txt\"],\n",
    "\t[\"公冶長\", \"05 Gong Ye Chang.txt\"],\n",
    "\t[\"雍也\", \"06 Yong Ye.txt\"],\n",
    "\t[\"述而\", \"07 Shu Er.txt\"],\n",
    "\t[\"泰伯\", \"08 Tai Bo.txt\"],\n",
    "\t[\"子罕\", \"09 Zi Han.txt\"],\n",
    "\t[\"鄉黨\", \"10 Xiang Dang.txt\"],\n",
    "\t[\"先進\", \"11 Xian Jin.txt\"],\n",
    "\t[\"顏淵\", \"12 Yan Yuan.txt\"],\n",
    "\t[\"子路\", \"13 Zi Lu.txt\"],\n",
    "\t[\"憲問\", \"14 Xian Wen.txt\"],\n",
    "\t[\"衛靈公\", \"15 Wei Ling Gong.txt\"],\n",
    "\t[\"季氏\", \"16 Ji Shi.txt\"],\n",
    "\t[\"陽貨\", \"17 Yang Huo.txt\"],\n",
    "\t[\"微子\", \"18 Wei Zi.txt\"],\n",
    "\t[\"子張\", \"19 Zi Zhang.txt\"],\n",
    "\t[\"堯曰\", \"20 Yao Yue.txt\"]\n",
    "]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "01 Xue Er.txt\n",
      "02 Wei Zheng.txt\n",
      "03 Ba Yi.txt\n",
      "04 Li Ren.txt\n",
      "05 Gong Ye Chang.txt\n",
      "06 Yong Ye.txt\n",
      "07 Shu Er.txt\n",
      "08 Tai Bo.txt\n",
      "09 Zi Han.txt\n",
      "10 Xiang Dang.txt\n",
      "11 Xian Jin.txt\n",
      "12 Yan Yuan.txt\n",
      "13 Zi Lu.txt\n",
      "14 Xian Wen.txt\n",
      "15 Wei Ling Gong.txt\n",
      "16 Ji Shi.txt\n",
      "17 Yang Huo.txt\n",
      "18 Wei Zi.txt\n",
      "19 Zi Zhang.txt\n",
      "20 Yao Yue.txt\n"
     ]
    }
   ],
   "source": [
    "for fname in os.listdir(WORK_DIR):\n",
    "    print(fname)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "def extract_chapter_lines():\n",
    "    text_list = []\n",
    "    for chapter_idx, (chapter, fname) in enumerate(CHAPTER_FILES):\n",
    "        print(\"processing file:{}\".format(fname))\n",
    "        fpath = os.path.join(WORK_DIR, fname)\n",
    "        if not os.path.exists(fpath):\n",
    "            print(\"can't find file {} for chapter:{}\".format(fname, chapter))\n",
    "            continue\n",
    "        with open(fpath, encoding='UTF-8') as fi:\n",
    "            for cnt, line in enumerate(fi):\n",
    "                line = line.strip()\n",
    "                if not line:\n",
    "                    continue\n",
    "                text_list.append([chapter_idx + 1, chapter, line])\n",
    "                if cnt % 10 == 0:\n",
    "                    print(\"processing cnt:{}\".format(cnt))\n",
    "    return text_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "processing file:01 Xue Er.txt\n",
      "processing cnt:10\n",
      "processing file:02 Wei Zheng.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:03 Ba Yi.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:04 Li Ren.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:05 Gong Ye Chang.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:06 Yong Ye.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing file:07 Shu Er.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing file:08 Tai Bo.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:09 Zi Han.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing file:10 Xiang Dang.txt\n",
      "processing cnt:10\n",
      "processing file:11 Xian Jin.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:12 Yan Yuan.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:13 Zi Lu.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing file:14 Xian Wen.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing cnt:40\n",
      "processing file:15 Wei Ling Gong.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing cnt:30\n",
      "processing cnt:40\n",
      "processing file:16 Ji Shi.txt\n",
      "processing cnt:10\n",
      "processing file:17 Yang Huo.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:18 Wei Zi.txt\n",
      "processing cnt:10\n",
      "processing file:19 Zi Zhang.txt\n",
      "processing cnt:10\n",
      "processing cnt:20\n",
      "processing file:20 Yao Yue.txt\n"
     ]
    }
   ],
   "source": [
    "text_list = extract_chapter_lines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "503"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "analects_df = pd.DataFrame(text_list, columns=['chapter_idx', 'chapter', 'content'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chapter_idx</th>\n",
       "      <th>chapter</th>\n",
       "      <th>content</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「學而時習之，不亦說乎？有朋自遠方來，不亦樂乎？人不知而不慍，不亦君子乎？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>有子曰：「其為人也孝弟，而好犯上者，鮮矣；不好犯上，而好作亂者，未之有也。君子務本，本立而道...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「巧言令色，鮮矣仁！」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>曾子曰：「吾日三省吾身：為人謀而不忠乎？與朋友交而不信乎？傳不習乎？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「道千乘之國：敬事而信，節用而愛人，使民以時。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「弟子入則孝，出則弟，謹而信，汎愛眾，而親仁。行有餘力，則以學文。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子夏曰：「賢賢易色，事父母能竭其力，事君能致其身，與朋友交言而有信。雖曰未學，吾必謂之學矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「君子不重則不威，學則不固。主忠信，無友不如己者，過則勿憚改。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>曾子曰：「慎終追遠，民德歸厚矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子禽問於子貢曰：「夫子至於是邦也，必聞其政，求之與？抑與之與？」子貢曰：「夫子溫、良、恭、儉...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「父在，觀其志；父沒，觀其行；三年無改於父之道，可謂孝矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>有子曰：「禮之用，和為貴。先王之道斯為美，小大由之。有所不行，知和而和，不以禮節之，亦不可行也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>有子曰：「信近於義，言可復也；恭近於禮，遠恥辱也；因不失其親，亦可宗也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「君子食無求飽，居無求安，敏於事而慎於言，就有道而正焉，可謂好學也已。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子貢曰：「貧而無諂，富而無驕，何如？」子曰：「可也。未若貧而樂，富而好禮者也。」子貢曰：「《...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1</td>\n",
       "      <td>學而</td>\n",
       "      <td>子曰：「不患人之不己知，患不知人也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「為政以德，譬如北辰，居其所而眾星共之。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「詩三百，一言以蔽之，曰『思無邪』。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「道之以政，齊之以刑，民免而無恥；道之以德，齊之以禮，有恥且格。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「吾十有五而志于學，三十而立，四十而不惑，五十而知天命，六十而耳順，七十而從心所欲，不...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>孟懿子問孝。子曰：「無違。」樊遲御，子告之曰：「孟孫問孝於我，我對曰『無違』。」樊遲曰：「何...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>孟武伯問孝。子曰：「父母唯其疾之憂。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子游問孝。子曰：「今之孝者，是謂能養。至於犬馬，皆能有養；不敬，何以別乎？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子夏問孝。子曰：「色難。有事弟子服其勞，有酒食先生饌，曾是以為孝乎？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「吾與回言終日，不違如愚。退而省其私，亦足以發。回也，不愚。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「視其所以，觀其所由，察其所安。人焉廋哉？人焉廋哉？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「溫故而知新，可以為師矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「君子不器。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子貢問君子。子曰：「先行其言，而後從之。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2</td>\n",
       "      <td>為政</td>\n",
       "      <td>子曰：「君子周而不比，小人比而不周。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>473</th>\n",
       "      <td>18</td>\n",
       "      <td>微子</td>\n",
       "      <td>周公謂魯公曰：「君子不施其親，不使大臣怨乎不以。故舊無大故，則不棄也。無求備於一人。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>474</th>\n",
       "      <td>18</td>\n",
       "      <td>微子</td>\n",
       "      <td>周有八士：伯達、伯適、仲突、仲忽、叔夜、叔夏、季隨、季騧。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>475</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子張曰：「士見危致命，見得思義，祭思敬，喪思哀，其可已矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>476</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子張曰：「執德不弘，信道不篤，焉能為有？焉能為亡？」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>477</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏之門人問交於子張。子張曰：「子夏云何？」對曰：「子夏曰：『可者與之，其不可者拒之。』」子...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>478</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「雖小道，必有可觀者焉；致遠恐泥，是以君子不為也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>479</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「日知其所亡，月無忘其所能，可謂好學也已矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>480</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「博學而篤志，切問而近思，仁在其中矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>481</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「百工居肆以成其事，君子學以致其道。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>482</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「小人之過也必文。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>483</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「君子有三變：望之儼然，即之也溫，聽其言也厲。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>484</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「君子信而後勞其民，未信則以為厲己也；信而後諫，未信則以為謗己也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>485</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「大德不踰閑，小德出入可也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>486</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子游曰：「子夏之門人小子，當洒掃、應對、進退，則可矣。抑末也，本之則無。如之何？」子夏聞之曰...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>487</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子夏曰：「仕而優則學，學而優則仕。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>488</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子游曰：「喪致乎哀而止。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>489</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子游曰：「吾友張也，為難能也。然而未仁。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>490</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>曾子曰：「堂堂乎張也，難與並為仁矣。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>491</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>曾子曰：「吾聞諸夫子：人未有自致者也，必也親喪乎！」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>492</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>曾子曰：「吾聞諸夫子：孟莊子之孝也，其他可能也；其不改父之臣，與父之政，是難能也。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>493</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>孟氏使陽膚為士師，問於曾子。曾子曰：「上失其道，民散久矣。如得其情，則哀矜而勿喜。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>494</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子貢曰：「紂之不善，不如是之甚也。是以君子惡居下流，天下之惡皆歸焉。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>子貢曰：「君子之過也，如日月之食焉：過也，人皆見之；更也，人皆仰之。」</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>衛公孫朝問於子貢曰：「仲尼焉學？」子貢曰：「文武之道，未墜於地，在人。賢者識其大者，不賢者識...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>叔孫武叔語大夫於朝，曰：「子貢賢於仲尼。」子服景伯以告子貢。子貢曰：「譬之宮牆，賜之牆也及肩...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>叔孫武叔毀仲尼。子貢曰：「無以為也，仲尼不可毀也。他人之賢者，丘陵也，猶可踰也；仲尼，日月也...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>19</td>\n",
       "      <td>子張</td>\n",
       "      <td>陳子禽謂子貢曰：「子為恭也，仲尼豈賢於子乎？」子貢曰：「君子一言以為知，一言以為不知，言不可...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>500</th>\n",
       "      <td>20</td>\n",
       "      <td>堯曰</td>\n",
       "      <td>堯曰：「咨！爾舜！天之曆數在爾躬。允執其中。四海困窮，天祿永終。」舜亦以命禹。曰：「予小子履...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>501</th>\n",
       "      <td>20</td>\n",
       "      <td>堯曰</td>\n",
       "      <td>子張問於孔子曰：「何如斯可以從政矣？」子曰：「尊五美，屏四惡，斯可以從政矣。」子張曰：「何謂...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>502</th>\n",
       "      <td>20</td>\n",
       "      <td>堯曰</td>\n",
       "      <td>子曰：「不知命，無以為君子也。不知禮，無以立也。不知言，無以知人也。」</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>503 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     chapter_idx chapter                                            content\n",
       "0              1      學而          子曰：「學而時習之，不亦說乎？有朋自遠方來，不亦樂乎？人不知而不慍，不亦君子乎？」\n",
       "1              1      學而  有子曰：「其為人也孝弟，而好犯上者，鮮矣；不好犯上，而好作亂者，未之有也。君子務本，本立而道...\n",
       "2              1      學而                                     子曰：「巧言令色，鮮矣仁！」\n",
       "3              1      學而                曾子曰：「吾日三省吾身：為人謀而不忠乎？與朋友交而不信乎？傳不習乎？」\n",
       "4              1      學而                        子曰：「道千乘之國：敬事而信，節用而愛人，使民以時。」\n",
       "5              1      學而              子曰：「弟子入則孝，出則弟，謹而信，汎愛眾，而親仁。行有餘力，則以學文。」\n",
       "6              1      學而    子夏曰：「賢賢易色，事父母能竭其力，事君能致其身，與朋友交言而有信。雖曰未學，吾必謂之學矣。」\n",
       "7              1      學而                子曰：「君子不重則不威，學則不固。主忠信，無友不如己者，過則勿憚改。」\n",
       "8              1      學而                                  曾子曰：「慎終追遠，民德歸厚矣。」\n",
       "9              1      學而  子禽問於子貢曰：「夫子至於是邦也，必聞其政，求之與？抑與之與？」子貢曰：「夫子溫、良、恭、儉...\n",
       "10             1      學而                  子曰：「父在，觀其志；父沒，觀其行；三年無改於父之道，可謂孝矣。」\n",
       "11             1      學而  有子曰：「禮之用，和為貴。先王之道斯為美，小大由之。有所不行，知和而和，不以禮節之，亦不可行也。」\n",
       "12             1      學而              有子曰：「信近於義，言可復也；恭近於禮，遠恥辱也；因不失其親，亦可宗也。」\n",
       "13             1      學而            子曰：「君子食無求飽，居無求安，敏於事而慎於言，就有道而正焉，可謂好學也已。」\n",
       "14             1      學而  子貢曰：「貧而無諂，富而無驕，何如？」子曰：「可也。未若貧而樂，富而好禮者也。」子貢曰：「《...\n",
       "15             1      學而                                子曰：「不患人之不己知，患不知人也。」\n",
       "16             2      為政                           子曰：「為政以德，譬如北辰，居其所而眾星共之。」\n",
       "17             2      為政                             子曰：「詩三百，一言以蔽之，曰『思無邪』。」\n",
       "18             2      為政               子曰：「道之以政，齊之以刑，民免而無恥；道之以德，齊之以禮，有恥且格。」\n",
       "19             2      為政  子曰：「吾十有五而志于學，三十而立，四十而不惑，五十而知天命，六十而耳順，七十而從心所欲，不...\n",
       "20             2      為政  孟懿子問孝。子曰：「無違。」樊遲御，子告之曰：「孟孫問孝於我，我對曰『無違』。」樊遲曰：「何...\n",
       "21             2      為政                                孟武伯問孝。子曰：「父母唯其疾之憂。」\n",
       "22             2      為政             子游問孝。子曰：「今之孝者，是謂能養。至於犬馬，皆能有養；不敬，何以別乎？」\n",
       "23             2      為政                子夏問孝。子曰：「色難。有事弟子服其勞，有酒食先生饌，曾是以為孝乎？」\n",
       "24             2      為政                 子曰：「吾與回言終日，不違如愚。退而省其私，亦足以發。回也，不愚。」\n",
       "25             2      為政                     子曰：「視其所以，觀其所由，察其所安。人焉廋哉？人焉廋哉？」\n",
       "26             2      為政                                  子曰：「溫故而知新，可以為師矣。」\n",
       "27             2      為政                                         子曰：「君子不器。」\n",
       "28             2      為政                              子貢問君子。子曰：「先行其言，而後從之。」\n",
       "29             2      為政                                子曰：「君子周而不比，小人比而不周。」\n",
       "..           ...     ...                                                ...\n",
       "473           18      微子        周公謂魯公曰：「君子不施其親，不使大臣怨乎不以。故舊無大故，則不棄也。無求備於一人。」\n",
       "474           18      微子                      周有八士：伯達、伯適、仲突、仲忽、叔夜、叔夏、季隨、季騧。\n",
       "475           19      子張                     子張曰：「士見危致命，見得思義，祭思敬，喪思哀，其可已矣。」\n",
       "476           19      子張                         子張曰：「執德不弘，信道不篤，焉能為有？焉能為亡？」\n",
       "477           19      子張  子夏之門人問交於子張。子張曰：「子夏云何？」對曰：「子夏曰：『可者與之，其不可者拒之。』」子...\n",
       "478           19      子張                     子夏曰：「雖小道，必有可觀者焉；致遠恐泥，是以君子不為也。」\n",
       "479           19      子張                        子夏曰：「日知其所亡，月無忘其所能，可謂好學也已矣。」\n",
       "480           19      子張                           子夏曰：「博學而篤志，切問而近思，仁在其中矣。」\n",
       "481           19      子張                            子夏曰：「百工居肆以成其事，君子學以致其道。」\n",
       "482           19      子張                                     子夏曰：「小人之過也必文。」\n",
       "483           19      子張                       子夏曰：「君子有三變：望之儼然，即之也溫，聽其言也厲。」\n",
       "484           19      子張             子夏曰：「君子信而後勞其民，未信則以為厲己也；信而後諫，未信則以為謗己也。」\n",
       "485           19      子張                                子夏曰：「大德不踰閑，小德出入可也。」\n",
       "486           19      子張  子游曰：「子夏之門人小子，當洒掃、應對、進退，則可矣。抑末也，本之則無。如之何？」子夏聞之曰...\n",
       "487           19      子張                                 子夏曰：「仕而優則學，學而優則仕。」\n",
       "488           19      子張                                      子游曰：「喪致乎哀而止。」\n",
       "489           19      子張                              子游曰：「吾友張也，為難能也。然而未仁。」\n",
       "490           19      子張                                曾子曰：「堂堂乎張也，難與並為仁矣。」\n",
       "491           19      子張                         曾子曰：「吾聞諸夫子：人未有自致者也，必也親喪乎！」\n",
       "492           19      子張         曾子曰：「吾聞諸夫子：孟莊子之孝也，其他可能也；其不改父之臣，與父之政，是難能也。」\n",
       "493           19      子張         孟氏使陽膚為士師，問於曾子。曾子曰：「上失其道，民散久矣。如得其情，則哀矜而勿喜。」\n",
       "494           19      子張                子貢曰：「紂之不善，不如是之甚也。是以君子惡居下流，天下之惡皆歸焉。」\n",
       "495           19      子張                子貢曰：「君子之過也，如日月之食焉：過也，人皆見之；更也，人皆仰之。」\n",
       "496           19      子張  衛公孫朝問於子貢曰：「仲尼焉學？」子貢曰：「文武之道，未墜於地，在人。賢者識其大者，不賢者識...\n",
       "497           19      子張  叔孫武叔語大夫於朝，曰：「子貢賢於仲尼。」子服景伯以告子貢。子貢曰：「譬之宮牆，賜之牆也及肩...\n",
       "498           19      子張  叔孫武叔毀仲尼。子貢曰：「無以為也，仲尼不可毀也。他人之賢者，丘陵也，猶可踰也；仲尼，日月也...\n",
       "499           19      子張  陳子禽謂子貢曰：「子為恭也，仲尼豈賢於子乎？」子貢曰：「君子一言以為知，一言以為不知，言不可...\n",
       "500           20      堯曰  堯曰：「咨！爾舜！天之曆數在爾躬。允執其中。四海困窮，天祿永終。」舜亦以命禹。曰：「予小子履...\n",
       "501           20      堯曰  子張問於孔子曰：「何如斯可以從政矣？」子曰：「尊五美，屏四惡，斯可以從政矣。」子張曰：「何謂...\n",
       "502           20      堯曰                子曰：「不知命，無以為君子也。不知禮，無以立也。不知言，無以知人也。」\n",
       "\n",
       "[503 rows x 3 columns]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chapter_idx</th>\n",
       "      <th>content</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>chapter</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>學而</th>\n",
       "      <td>1</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>為政</th>\n",
       "      <td>2</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>八佾</th>\n",
       "      <td>3</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>里仁</th>\n",
       "      <td>4</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>公冶長</th>\n",
       "      <td>5</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>雍也</th>\n",
       "      <td>6</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>述而</th>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>泰伯</th>\n",
       "      <td>8</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>子罕</th>\n",
       "      <td>9</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>鄉黨</th>\n",
       "      <td>10</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>先進</th>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>顏淵</th>\n",
       "      <td>12</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>子路</th>\n",
       "      <td>13</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>憲問</th>\n",
       "      <td>14</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>衛靈公</th>\n",
       "      <td>15</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>季氏</th>\n",
       "      <td>16</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>陽貨</th>\n",
       "      <td>17</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>微子</th>\n",
       "      <td>18</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>子張</th>\n",
       "      <td>19</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>堯曰</th>\n",
       "      <td>20</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         chapter_idx  content\n",
       "chapter                      \n",
       "學而                 1       16\n",
       "為政                 2       24\n",
       "八佾                 3       26\n",
       "里仁                 4       26\n",
       "公冶長                5       28\n",
       "雍也                 6       30\n",
       "述而                 7       38\n",
       "泰伯                 8       21\n",
       "子罕                 9       31\n",
       "鄉黨                10       18\n",
       "先進                11       26\n",
       "顏淵                12       24\n",
       "子路                13       30\n",
       "憲問                14       44\n",
       "衛靈公               15       42\n",
       "季氏                16       14\n",
       "陽貨                17       26\n",
       "微子                18       11\n",
       "子張                19       25\n",
       "堯曰                20        3"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df.groupby('chapter').agg({'chapter_idx':'min', 'content':'count'}).sort_values('chapter_idx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "def char_count(line):\n",
    "    if line is None:\n",
    "        return 0\n",
    "    return len(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "PUNC_REGEX = r'：|「|，|。|」|『|』|？|《|》|；|！|、'\n",
    "def raw_char_count(line):\n",
    "    raw_line = re.sub(PUNC_REGEX, '', line)\n",
    "    return char_count(raw_line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_sentences(line):\n",
    "    raw_sentences = re.split(\"：|，|。|；|？\", line)\n",
    "    sentences = []\n",
    "    for s in raw_sentences:\n",
    "        sentence = re.sub(PUNC_REGEX, '', s)\n",
    "        if sentence:\n",
    "            sentences.append(sentence)\n",
    "    return sentences"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['子曰', '學而時習之', '不亦說乎', '有朋自遠方來', '不亦樂乎', '人不知而不慍', '不亦君子乎']"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_sentences(analects_df['content'].loc[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'子曰：「學而時習之，不亦說乎？有朋自遠方來，不亦樂乎？人不知而不慍，不亦君子乎？」'"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df['content'].loc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "子曰學而時習之不亦說乎有朋自遠方來不亦樂乎人不知而不慍不亦君子乎\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'子曰學而時習之不亦說乎有朋自遠方來不亦樂乎人不知而不慍不亦君子乎'"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw_char_count(analects_df['content'].loc[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "子曰學而時習之不亦說乎有朋自遠方來不亦樂乎人不知而不慍不亦君子乎\n",
      "有子曰其為人也孝弟而好犯上者鮮矣不好犯上而好作亂者未之有也君子務本本立而道生孝弟也者其為仁之本與\n",
      "子曰巧言令色鮮矣仁\n",
      "曾子曰吾日三省吾身為人謀而不忠乎與朋友交而不信乎傳不習乎\n",
      "子曰道千乘之國敬事而信節用而愛人使民以時\n",
      "子曰弟子入則孝出則弟謹而信汎愛眾而親仁行有餘力則以學文\n",
      "子夏曰賢賢易色事父母能竭其力事君能致其身與朋友交言而有信雖曰未學吾必謂之學矣\n",
      "子曰君子不重則不威學則不固主忠信無友不如己者過則勿憚改\n",
      "曾子曰慎終追遠民德歸厚矣\n",
      "子禽問於子貢曰夫子至於是邦也必聞其政求之與抑與之與子貢曰夫子溫良恭儉讓以得之夫子之求之也其諸異乎人之求之與\n",
      "子曰父在觀其志父沒觀其行三年無改於父之道可謂孝矣\n",
      "有子曰禮之用和為貴先王之道斯為美小大由之有所不行知和而和不以禮節之亦不可行也\n",
      "有子曰信近於義言可復也恭近於禮遠恥辱也因不失其親亦可宗也\n",
      "子曰君子食無求飽居無求安敏於事而慎於言就有道而正焉可謂好學也已\n",
      "子貢曰貧而無諂富而無驕何如子曰可也未若貧而樂富而好禮者也子貢曰詩云如切如磋如琢如磨其斯之謂與子曰賜也始可與言詩已矣告諸往而知來者\n",
      "子曰不患人之不己知患不知人也\n",
      "子曰為政以德譬如北辰居其所而眾星共之\n",
      "子曰詩三百一言以蔽之曰思無邪\n",
      "子曰道之以政齊之以刑民免而無恥道之以德齊之以禮有恥且格\n",
      "子曰吾十有五而志于學三十而立四十而不惑五十而知天命六十而耳順七十而從心所欲不踰矩\n",
      "孟懿子問孝子曰無違樊遲御子告之曰孟孫問孝於我我對曰無違樊遲曰何謂也子曰生事之以禮死葬之以禮祭之以禮\n",
      "孟武伯問孝子曰父母唯其疾之憂\n",
      "子游問孝子曰今之孝者是謂能養至於犬馬皆能有養不敬何以別乎\n",
      "子夏問孝子曰色難有事弟子服其勞有酒食先生饌曾是以為孝乎\n",
      "子曰吾與回言終日不違如愚退而省其私亦足以發回也不愚\n",
      "子曰視其所以觀其所由察其所安人焉廋哉人焉廋哉\n",
      "子曰溫故而知新可以為師矣\n",
      "子曰君子不器\n",
      "子貢問君子子曰先行其言而後從之\n",
      "子曰君子周而不比小人比而不周\n",
      "子曰學而不思則罔思而不學則殆\n",
      "子曰攻乎異端斯害也已\n",
      "子曰由誨女知之乎知之為知之不知為不知是知也\n",
      "子張學干祿子曰多聞闕疑慎言其餘則寡尤多見闕殆慎行其餘則寡悔言寡尤行寡悔祿在其中矣\n",
      "哀公問曰何為則民服孔子對曰舉直錯諸枉則民服舉枉錯諸直則民不服\n",
      "季康子問使民敬忠以勸如之何子曰臨之以莊則敬孝慈則忠舉善而教不能則勸\n",
      "或謂孔子曰子奚不為政子曰書云孝乎惟孝友于兄弟施於有政是亦為政奚其為為政\n",
      "子曰人而無信不知其可也大車無輗小車無軏其何以行之哉\n",
      "子張問十世可知也子曰殷因於夏禮所損益可知也周因於殷禮所損益可知也其或繼周者雖百世可知也\n",
      "子曰非其鬼而祭之諂也見義不為無勇也\n",
      "孔子謂季氏八佾舞於庭是可忍也孰不可忍也\n",
      "三家者以雍徹子曰相維辟公天子穆穆奚取於三家之堂\n",
      "子曰人而不仁如禮何人而不仁如樂何\n",
      "林放問禮之本子曰大哉問禮與其奢也寧儉喪與其易也寧戚\n",
      "子曰夷狄之有君不如諸夏之亡也\n",
      "季氏旅於泰山子謂冉有曰女弗能救與對曰不能子曰嗚呼曾謂泰山不如林放乎\n",
      "子曰君子無所爭必也射乎揖讓而升下而飲其爭也君子\n",
      "子夏問曰巧笑倩兮美目盼兮素以為絢兮何謂也子曰繪事後素曰禮後乎子曰起予者商也始可與言詩已矣\n",
      "子曰夏禮吾能言之杞不足徵也殷禮吾能言之宋不足徵也文獻不足故也足則吾能徵之矣\n",
      "子曰禘自既灌而往者吾不欲觀之矣\n",
      "或問禘之說子曰不知也知其說者之於天下也其如示諸斯乎指其掌\n",
      "祭如在祭神如神在子曰吾不與祭如不祭\n",
      "王孫賈問曰與其媚於奧寧媚於竈何謂也子曰不然獲罪於天無所禱也\n",
      "子曰周監於二代郁郁乎文哉吾從周\n",
      "子入大廟每事問或曰孰謂鄹人之子知禮乎入大廟每事問子聞之曰是禮也\n",
      "子曰射不主皮為力不同科古之道也\n",
      "子貢欲去告朔之餼羊子曰賜也爾愛其羊我愛其禮\n",
      "子曰事君盡禮人以為諂也\n",
      "定公問君使臣臣事君如之何孔子對曰君使臣以禮臣事君以忠\n",
      "子曰關雎樂而不淫哀而不傷\n",
      "哀公問社於宰我宰我對曰夏后氏以松殷人以柏周人以栗曰使民戰栗子聞之曰成事不說遂事不諫既往不咎\n",
      "子曰管仲之器小哉或曰管仲儉乎曰管氏有三歸官事不攝焉得儉然則管仲知禮乎曰邦君樹塞門管氏亦樹塞門邦君為兩君之好有反坫管氏亦有反坫管氏而知禮孰不知禮\n",
      "子語魯大師樂曰樂其可知也始作翕如也從之純如也皦如也繹如也以成\n",
      "儀封人請見曰君子之至於斯也吾未嘗不得見也從者見之出曰二三子何患於喪乎天下之無道也久矣天將以夫子為木鐸\n",
      "子謂韶盡美矣又盡善也謂武盡美矣未盡善也\n",
      "子曰居上不寬為禮不敬臨喪不哀吾何以觀之哉\n",
      "子曰里仁為美擇不處仁焉得知\n",
      "子曰不仁者不可以久處約不可以長處樂仁者安仁知者利仁\n",
      "子曰唯仁者能好人能惡人\n",
      "子曰苟志於仁矣無惡也\n",
      "子曰富與貴是人之所欲也不以其道得之不處也貧與賤是人之所惡也不以其道得之不去也君子去仁惡乎成名君子無終食之間違仁造次必於是顛沛必於是\n",
      "子曰我未見好仁者惡不仁者好仁者無以尚之惡不仁者其為仁矣不使不仁者加乎其身有能一日用其力於仁矣乎我未見力不足者蓋有之矣我未之見也\n",
      "子曰人之過也各於其黨觀過斯知仁矣\n",
      "子曰朝聞道夕死可矣\n",
      "子曰士志於道而恥惡衣惡食者未足與議也\n",
      "子曰君子之於天下也無適也無莫也義之與比\n",
      "子曰君子懷德小人懷土君子懷刑小人懷惠\n",
      "子曰放於利而行多怨\n",
      "子曰能以禮讓為國乎何有不能以禮讓為國如禮何\n",
      "子曰不患無位患所以立不患莫己知求為可知也\n",
      "子曰參乎吾道一以貫之曾子曰唯子出門人問曰何謂也曾子曰夫子之道忠恕而已矣\n",
      "子曰君子喻於義小人喻於利\n",
      "子曰見賢思齊焉見不賢而內自省也\n",
      "子曰事父母幾諫見志不從又敬不違勞而不怨\n",
      "子曰父母在不遠遊遊必有方\n",
      "子曰三年無改於父之道可謂孝矣\n",
      "子曰父母之年不可不知也一則以喜一則以懼\n",
      "子曰古者言之不出恥躬之不逮也\n",
      "子曰以約失之者鮮矣\n",
      "子曰君子欲訥於言而敏於行\n",
      "子曰德不孤必有鄰\n",
      "子游曰事君數斯辱矣朋友數斯疏矣\n",
      "子謂公冶長可妻也雖在縲絏之中非其罪也以其子妻之\n",
      "子謂南容邦有道不廢邦無道免於刑戮以其兄之子妻之\n",
      "子謂子賤君子哉若人魯無君子者斯焉取斯\n",
      "子貢問曰賜也何如子曰女器也曰何器也曰瑚璉也\n",
      "或曰雍也仁而不佞子曰焉用佞禦人以口給屢憎於人不知其仁焉用佞\n",
      "子使漆雕開仕對曰吾斯之未能信子說\n",
      "子曰道不行乘桴浮于海從我者其由與子路聞之喜子曰由也好勇過我無所取材\n",
      "孟武伯問子路仁乎子曰不知也又問子曰由也千乘之國可使治其賦也不知其仁也求也何如子曰求也千室之邑百乘之家可使為之宰也不知其仁也赤也何如子曰赤也束帶立於朝可使與賓客言也不知其仁也\n",
      "子謂子貢曰女與回也孰愈對曰賜也何敢望回回也聞一以知十賜也聞一以知二子曰弗如也吾與女弗如也\n",
      "宰予晝寢子曰朽木不可雕也糞土之牆不可杇也於予與何誅子曰始吾於人也聽其言而信其行今吾於人也聽其言而觀其行於予與改是\n",
      "子曰吾未見剛者或對曰申棖子曰棖也慾焉得剛\n",
      "子貢曰我不欲人之加諸我也吾亦欲無加諸人子曰賜也非爾所及也\n",
      "子貢曰夫子之文章可得而聞也夫子之言性與天道不可得而聞也\n",
      "子路有聞未之能行唯恐有聞\n",
      "子貢問曰孔文子何以謂之文也子曰敏而好學不恥下問是以謂之文也\n",
      "子謂子產有君子之道四焉其行己也恭其事上也敬其養民也惠其使民也義\n",
      "子曰晏平仲善與人交久而敬之\n",
      "子曰臧文仲居蔡山節藻梲何如其知也\n",
      "子張問曰令尹子文三仕為令尹無喜色三已之無慍色舊令尹之政必以告新令尹何如子曰忠矣曰仁矣乎曰未知焉得仁崔子弒齊君陳文子有馬十乘棄而違之至於他邦則曰猶吾大夫崔子也違之之一邦則又曰猶吾大夫崔子也違之何如子曰清矣曰仁矣乎曰未知焉得仁\n",
      "季文子三思而後行子聞之曰再斯可矣\n",
      "子曰甯武子邦有道則知邦無道則愚其知可及也其愚不可及也\n",
      "子在陳曰歸與歸與吾黨之小子狂簡斐然成章不知所以裁之\n",
      "子曰伯夷叔齊不念舊惡怨是用希\n",
      "子曰孰謂微生高直或乞醯焉乞諸其鄰而與之\n",
      "子曰巧言令色足恭左丘明恥之丘亦恥之匿怨而友其人左丘明恥之丘亦恥之\n",
      "顏淵季路侍子曰盍各言爾志子路曰願車馬衣輕裘與朋友共敝之而無憾顏淵曰願無伐善無施勞子路曰願聞子之志子曰老者安之朋友信之少者懷之\n",
      "子曰已矣乎吾未見能見其過而內自訟者也\n",
      "子曰十室之邑必有忠信如丘者焉不如丘之好學也\n",
      "子曰雍也可使南面\n",
      "仲弓問子桑伯子子曰可也簡仲弓曰居敬而行簡以臨其民不亦可乎居簡而行簡無乃大簡乎子曰雍之言然\n",
      "哀公問弟子孰為好學孔子對曰有顏回者好學不遷怒不貳過不幸短命死矣今也則亡未聞好學者也\n",
      "子華使於齊冉子為其母請粟子曰與之釜請益曰與之庾冉子與之粟五秉子曰赤之適齊也乘肥馬衣輕裘吾聞之也君子周急不繼富\n",
      "原思為之宰與之粟九百辭子曰毋以與爾鄰里鄉黨乎\n",
      "子謂仲弓曰犂牛之子騂且角雖欲勿用山川其舍諸\n",
      "子曰回也其心三月不違仁其餘則日月至焉而已矣\n",
      "季康子問仲由可使從政也與子曰由也果於從政乎何有曰賜也可使從政也與曰賜也達於從政乎何有曰求也可使從政也與曰求也藝於從政乎何有\n",
      "季氏使閔子騫為費宰閔子騫曰善為我辭焉如有復我者則吾必在汶上矣\n",
      "伯牛有疾子問之自牖執其手曰亡之命矣夫斯人也而有斯疾也斯人也而有斯疾也\n",
      "子曰賢哉回也一簞食一瓢飲在陋巷人不堪其憂回也不改其樂賢哉回也\n",
      "冉求曰非不說子之道力不足也子曰力不足者中道而廢今女畫\n",
      "子謂子夏曰女為君子儒無為小人儒\n",
      "子游為武城宰子曰女得人焉爾乎曰有澹臺滅明者行不由徑非公事未嘗至於偃之室也\n",
      "子曰孟之反不伐奔而殿將入門策其馬曰非敢後也馬不進也\n",
      "子曰不有祝鮀之佞而有宋朝之美難乎免於今之世矣\n",
      "子曰誰能出不由戶何莫由斯道也\n",
      "子曰質勝文則野文勝質則史文質彬彬然後君子\n",
      "子曰人之生也直罔之生也幸而免\n",
      "子曰知之者不如好之者好之者不如樂之者\n",
      "子曰中人以上可以語上也中人以下不可以語上也\n",
      "樊遲問知子曰務民之義敬鬼神而遠之可謂知矣問仁曰仁者先難而後獲可謂仁矣\n",
      "子曰知者樂水仁者樂山知者動仁者靜知者樂仁者壽\n",
      "子曰齊一變至於魯魯一變至於道\n",
      "子曰觚不觚觚哉觚哉\n",
      "宰我問曰仁者雖告之曰井有仁焉其從之也子曰何為其然也君子可逝也不可陷也可欺也不可罔也\n",
      "子曰君子博學於文約之以禮亦可以弗畔矣夫\n",
      "子見南子子路不說夫子矢之曰予所否者天厭之天厭之\n",
      "子曰中庸之為德也其至矣乎民鮮久矣\n",
      "子貢曰如有博施於民而能濟眾何如可謂仁乎子曰何事於仁必也聖乎堯舜其猶病諸夫仁者己欲立而立人己欲達而達人能近取譬可謂仁之方也已\n",
      "子曰述而不作信而好古竊比於我老彭\n",
      "子曰默而識之學而不厭誨人不倦何有於我哉\n",
      "子曰德之不脩學之不講聞義不能徙不善不能改是吾憂也\n",
      "子之燕居申申如也夭夭如也\n",
      "子曰甚矣吾衰也久矣吾不復夢見周公\n",
      "子曰志於道據於德依於仁游於藝\n",
      "子曰自行束脩以上吾未嘗無誨焉\n",
      "子曰不憤不啟不悱不發舉一隅不以三隅反則不復也\n",
      "子食於有喪者之側未嘗飽也\n",
      "子於是日哭則不歌\n",
      "子謂顏淵曰用之則行舍之則藏唯我與爾有是夫子路曰子行三軍則誰與子曰暴虎馮河死而無悔者吾不與也必也臨事而懼好謀而成者也\n",
      "子曰富而可求也雖執鞭之士吾亦為之如不可求從吾所好\n",
      "子之所慎齊戰疾\n",
      "子在齊聞韶三月不知肉味曰不圖為樂之至於斯也\n",
      "冉有曰夫子為衛君乎子貢曰諾吾將問之入曰伯夷叔齊何人也曰古之賢人也曰怨乎曰求仁而得仁又何怨出曰夫子不為也\n",
      "子曰飯疏食飲水曲肱而枕之樂亦在其中矣不義而富且貴於我如浮雲\n",
      "子曰加我數年五十以學易可以無大過矣\n",
      "子所雅言詩書執禮皆雅言也\n",
      "葉公問孔子於子路子路不對子曰女奚不曰其為人也發憤忘食樂以忘憂不知老之將至云爾\n",
      "子曰我非生而知之者好古敏以求之者也\n",
      "子不語怪力亂神\n",
      "子曰三人行必有我師焉擇其善者而從之其不善者而改之\n",
      "子曰天生德於予桓魋其如予何\n",
      "子曰二三子以我為隱乎吾無隱乎爾吾無行而不與二三子者是丘也\n",
      "子以四教文行忠信\n",
      "子曰聖人吾不得而見之矣得見君子者斯可矣子曰善人吾不得而見之矣得見有恆者斯可矣亡而為有虛而為盈約而為泰難乎有恆矣\n",
      "子釣而不綱弋不射宿\n",
      "子曰蓋有不知而作之者我無是也多聞擇其善者而從之多見而識之知之次也\n",
      "互鄉難與言童子見門人惑子曰與其進也不與其退也唯何甚人潔己以進與其潔也不保其往也\n",
      "子曰仁遠乎哉我欲仁斯仁至矣\n",
      "陳司敗問昭公知禮乎孔子曰知禮孔子退揖巫馬期而進之曰吾聞君子不黨君子亦黨乎君取於吳為同姓謂之吳孟子君而知禮孰不知禮巫馬期以告子曰丘也幸苟有過人必知之\n",
      "子與人歌而善必使反之而後和之\n",
      "子曰文莫吾猶人也躬行君子則吾未之有得\n",
      "子曰若聖與仁則吾豈敢抑為之不厭誨人不倦則可謂云爾已矣公西華曰正唯弟子不能學也\n",
      "子疾病子路請禱子曰有諸子路對曰有之誄曰禱爾于上下神祇子曰丘之禱久矣\n",
      "子曰奢則不孫儉則固與其不孫也寧固\n",
      "子曰君子坦蕩蕩小人長戚戚\n",
      "子溫而厲威而不猛恭而安\n",
      "子曰泰伯其可謂至德也已矣三以天下讓民無得而稱焉\n",
      "子曰恭而無禮則勞慎而無禮則葸勇而無禮則亂直而無禮則絞君子篤於親則民興於仁故舊不遺則民不偷\n",
      "曾子有疾召門弟子曰啟予足啟予手詩云戰戰兢兢如臨深淵如履薄冰而今而後吾知免夫小子\n",
      "曾子有疾孟敬子問之曾子言曰鳥之將死其鳴也哀人之將死其言也善君子所貴乎道者三動容貌斯遠暴慢矣正顏色斯近信矣出辭氣斯遠鄙倍矣籩豆之事則有司存\n",
      "曾子曰以能問於不能以多問於寡有若無實若虛犯而不校昔者吾友嘗從事於斯矣\n",
      "曾子曰可以託六尺之孤可以寄百里之命臨大節而不可奪也君子人與君子人也\n",
      "曾子曰士不可以不弘毅任重而道遠仁以為己任不亦重乎死而後已不亦遠乎\n",
      "子曰興於詩立於禮成於樂\n",
      "子曰民可使由之不可使知之\n",
      "子曰好勇疾貧亂也人而不仁疾之已甚亂也\n",
      "子曰如有周公之才之美使驕且吝其餘不足觀也已\n",
      "子曰三年學不至於穀不易得也\n",
      "子曰篤信好學守死善道危邦不入亂邦不居天下有道則見無道則隱邦有道貧且賤焉恥也邦無道富且貴焉恥也\n",
      "子曰不在其位不謀其政\n",
      "子曰師摯之始關雎之亂洋洋乎盈耳哉\n",
      "子曰狂而不直侗而不愿悾悾而不信吾不知之矣\n",
      "子曰學如不及猶恐失之\n",
      "子曰巍巍乎舜禹之有天下也而不與焉\n",
      "子曰大哉堯之為君也巍巍乎唯天為大唯堯則之蕩蕩乎民無能名焉巍巍乎其有成功也煥乎其有文章\n",
      "舜有臣五人而天下治武王曰予有亂臣十人孔子曰才難不其然乎唐虞之際於斯為盛有婦人焉九人而已三分天下有其二以服事殷周之德其可謂至德也已矣\n",
      "子曰禹吾無間然矣菲飲食而致孝乎鬼神惡衣服而致美乎黻冕卑宮室而盡力乎溝洫禹吾無間然矣\n",
      "子罕言利與命與仁\n",
      "達巷黨人曰大哉孔子博學而無所成名子聞之謂門弟子曰吾何執執御乎執射乎吾執御矣\n",
      "子曰麻冕禮也今也純儉吾從眾拜下禮也今拜乎上泰也雖違眾吾從下\n",
      "子絕四毋意毋必毋固毋我\n",
      "子畏於匡曰文王既沒文不在茲乎天之將喪斯文也後死者不得與於斯文也天之未喪斯文也匡人其如予何\n",
      "大宰問於子貢曰夫子聖者與何其多能也子貢曰固天縱之將聖又多能也子聞之曰大宰知我乎吾少也賤故多能鄙事君子多乎哉不多也\n",
      "牢曰子云吾不試故藝\n",
      "子曰吾有知乎哉無知也有鄙夫問於我空空如也我叩其兩端而竭焉\n",
      "子曰鳳鳥不至河不出圖吾已矣夫\n",
      "子見齊衰者冕衣裳者與瞽者見之雖少必作過之必趨\n",
      "顏淵喟然歎曰仰之彌高鑽之彌堅瞻之在前忽焉在後夫子循循然善誘人博我以文約我以禮欲罷不能既竭吾才如有所立卓爾雖欲從之末由也已\n",
      "子疾病子路使門人為臣病閒曰久矣哉由之行詐也無臣而為有臣吾誰欺欺天乎且予與其死於臣之手也無寧死於二三子之手乎且予縱不得大葬予死於道路乎\n",
      "子貢曰有美玉於斯韞匵而藏諸求善賈而沽諸子曰沽之哉沽之哉我待賈者也\n",
      "子欲居九夷或曰陋如之何子曰君子居之何陋之有\n",
      "子曰吾自衛反魯然後樂正雅頌各得其所\n",
      "子曰出則事公卿入則事父兄喪事不敢不勉不為酒困何有於我哉\n",
      "子在川上曰逝者如斯夫不舍晝夜\n",
      "子曰吾未見好德如好色者也\n",
      "子曰譬如為山未成一簣止吾止也譬如平地雖覆一簣進吾往也\n",
      "子曰語之而不惰者其回也與\n",
      "子謂顏淵曰惜乎吾見其進也未見其止也\n",
      "子曰苗而不秀者有矣夫秀而不實者有矣夫\n",
      "子曰後生可畏焉知來者之不如今也四十五十而無聞焉斯亦不足畏也已\n",
      "子曰法語之言能無從乎改之為貴巽與之言能無說乎繹之為貴說而不繹從而不改吾末如之何也已矣\n",
      "子曰主忠信毋友不如己者過則勿憚改\n",
      "子曰三軍可奪帥也匹夫不可奪志也\n",
      "子曰衣敝縕袍與衣狐貉者立而不恥者其由也與不忮不求何用不臧子路終身誦之子曰是道也何足以臧\n",
      "子曰歲寒然後知松柏之後彫也\n",
      "子曰知者不惑仁者不憂勇者不懼\n",
      "子曰可與共學未可與適道可與適道未可與立可與立未可與權\n",
      "唐棣之華偏其反而豈不爾思室是遠而子曰未之思也夫何遠之有\n",
      "孔子於鄉黨恂恂如也似不能言者其在宗廟朝廷便便言唯謹爾\n",
      "朝與下大夫言侃侃如也與上大夫言誾誾如也君在踧踖如也與與如也\n",
      "君召使擯色勃如也足躩如也揖所與立左右手衣前後襜如也趨進翼如也賓退必復命曰賓不顧矣\n",
      "入公門鞠躬如也如不容立不中門行不履閾過位色勃如也足躩如也其言似不足者攝齊升堂鞠躬如也屏氣似不息者出降一等逞顏色怡怡如也沒階趨進翼如也復其位踧踖如也\n",
      "執圭鞠躬如也如不勝上如揖下如授勃如戰色足蹜蹜如有循享禮有容色私覿愉愉如也\n",
      "君子不以紺緅飾紅紫不以為褻服當暑袗絺綌必表而出之緇衣羔裘素衣麑裘黃衣狐裘褻裘長短右袂必有寢衣長一身有半狐貉之厚以居去喪無所不佩非帷裳必殺之羔裘玄冠不以弔吉月必朝服而朝\n",
      "齊必有明衣布齊必變食居必遷坐\n",
      "食不厭精膾不厭細食饐而餲魚餒而肉敗不食色惡不食臭惡不食失飪不食不時不食割不正不食不得其醬不食肉雖多不使勝食氣惟酒無量不及亂沽酒市脯不食不撤薑食不多食祭於公不宿肉祭肉不出三日出三日不食之矣食不語寢不言雖疏食菜羹瓜祭必齊如也\n",
      "席不正不坐\n",
      "鄉人飲酒杖者出斯出矣鄉人儺朝服而立於阼階\n",
      "問人於他邦再拜而送之康子饋藥拜而受之曰丘未達不敢嘗\n",
      "廄焚子退朝曰傷人乎不問馬\n",
      "君賜食必正席先嘗之君賜腥必熟而薦之君賜生必畜之侍食於君君祭先飯疾君視之東首加朝服拖紳君命召不俟駕行矣\n",
      "入太廟每事問\n",
      "朋友死無所歸曰於我殯朋友之饋雖車馬非祭肉不拜\n",
      "寢不尸居不容見齊衰者雖狎必變見冕者與瞽者雖褻必以貌凶服者式之式負版者有盛饌必變色而作迅雷風烈必變\n",
      "升車必正立執綏車中不內顧不疾言不親指\n",
      "色斯舉矣翔而後集曰山梁雌雉時哉時哉子路共之三嗅而作\n",
      "子曰先進於禮樂野人也後進於禮樂君子也如用之則吾從先進\n",
      "子曰從我於陳蔡者皆不及門也\n",
      "德行顏淵閔子騫冉伯牛仲弓言語宰我子貢政事冉有季路文學子游子夏\n",
      "子曰回也非助我者也於吾言無所不說\n",
      "子曰孝哉閔子騫人不間於其父母昆弟之言\n",
      "南容三復白圭孔子以其兄之子妻之\n",
      "季康子問弟子孰為好學孔子對曰有顏回者好學不幸短命死矣今也則亡\n",
      "顏淵死顏路請子之車以為之椁子曰才不才亦各言其子也鯉也死有棺而無椁吾不徒行以為之椁以吾從大夫之後不可徒行也\n",
      "顏淵死子曰噫天喪予天喪予\n",
      "顏淵死子哭之慟從者曰子慟矣曰有慟乎非夫人之為慟而誰為\n",
      "顏淵死門人欲厚葬之子曰不可門人厚葬之子曰回也視予猶父也予不得視猶子也非我也夫二三子也\n",
      "季路問事鬼神子曰未能事人焉能事鬼敢問死曰未知生焉知死\n",
      "閔子侍側誾誾如也子路行行如也冉有子貢侃侃如也子樂若由也不得其死然\n",
      "魯人為長府閔子騫曰仍舊貫如之何何必改作子曰夫人不言言必有中\n",
      "子曰由之瑟奚為於丘之門門人不敬子路子曰由也升堂矣未入於室也\n",
      "子貢問師與商也孰賢子曰師也過商也不及曰然則師愈與子曰過猶不及\n",
      "季氏富於周公而求也為之聚斂而附益之子曰非吾徒也小子鳴鼓而攻之可也\n",
      "柴也愚參也魯師也辟由也喭\n",
      "子曰回也其庶乎屢空賜不受命而貨殖焉億則屢中\n",
      "子張問善人之道子曰不踐跡亦不入於室\n",
      "子曰論篤是與君子者乎色莊者乎\n",
      "子路問聞斯行諸子曰有父兄在如之何其聞斯行之冉有問聞斯行諸子曰聞斯行之公西華曰由也問聞斯行諸子曰有父兄在求也問聞斯行諸子曰聞斯行之赤也惑敢問子曰求也退故進之由也兼人故退之\n",
      "子畏於匡顏淵後子曰吾以女為死矣曰子在回何敢死\n",
      "季子然問仲由冉求可謂大臣與子曰吾以子為異之問曾由與求之問所謂大臣者以道事君不可則止今由與求也可謂具臣矣曰然則從之者與子曰弒父與君亦不從也\n",
      "子路使子羔為費宰子曰賊夫人之子子路曰有民人焉有社稷焉何必讀書然後為學子曰是故惡夫佞者\n",
      "子路曾皙冉有公西華侍坐子曰以吾一日長乎爾毋吾以也居則曰不吾知也如或知爾則何以哉子路率爾而對曰千乘之國攝乎大國之間加之以師旅因之以饑饉由也為之比及三年可使有勇且知方也夫子哂之求爾何如對曰方六七十如五六十求也為之比及三年可使足民如其禮樂以俟君子赤爾何如對曰非曰能之願學焉宗廟之事如會同端章甫願為小相焉點爾何如鼓瑟希鏗爾舍瑟而作對曰異乎三子者之撰子曰何傷乎亦各言其志也曰莫春者春服既成冠者五六人童子六七人浴乎沂風乎舞雩詠而歸夫子喟然歎曰吾與點也三子者出曾皙後曾皙曰夫三子者之言何如子曰亦各言其志也已矣曰夫子何哂由也曰為國以禮其言不讓是故哂之唯求則非邦也與安見方六七十如五六十而非邦也者唯赤則非邦也與宗廟會同非諸侯而何赤也為之小孰能為之大\n",
      "顏淵問仁子曰克己復禮為仁一日克己復禮天下歸仁焉為仁由己而由人乎哉顏淵曰請問其目子曰非禮勿視非禮勿聽非禮勿言非禮勿動顏淵曰回雖不敏請事斯語矣\n",
      "仲弓問仁子曰出門如見大賓使民如承大祭己所不欲勿施於人在邦無怨在家無怨仲弓曰雍雖不敏請事斯語矣\n",
      "司馬牛問仁子曰仁者其言也訒曰其言也訒斯謂之仁已乎子曰為之難言之得無訒乎\n",
      "司馬牛問君子子曰君子不憂不懼曰不憂不懼斯謂之君子已乎子曰內省不疚夫何憂何懼\n",
      "司馬牛憂曰人皆有兄弟我獨亡子夏曰商聞之矣死生有命富貴在天君子敬而無失與人恭而有禮四海之內皆兄弟也君子何患乎無兄弟也\n",
      "子張問明子曰浸潤之譖膚受之愬不行焉可謂明也已矣浸潤之譖膚受之愬不行焉可謂遠也已矣\n",
      "子貢問政子曰足食足兵民信之矣子貢曰必不得已而去於斯三者何先曰去兵子貢曰必不得已而去於斯二者何先曰去食自古皆有死民無信不立\n",
      "棘子成曰君子質而已矣何以文為子貢曰惜乎夫子之說君子也駟不及舌文猶質也質猶文也虎豹之鞟猶犬羊之鞟\n",
      "哀公問於有若曰年饑用不足如之何有若對曰盍徹乎曰二吾猶不足如之何其徹也對曰百姓足君孰與不足百姓不足君孰與足\n",
      "子張問崇德辨惑子曰主忠信徙義崇德也愛之欲其生惡之欲其死既欲其生又欲其死是惑也誠不以富亦祗以異\n",
      "齊景公問政於孔子孔子對曰君君臣臣父父子子公曰善哉信如君不君臣不臣父不父子不子雖有粟吾得而食諸\n",
      "子曰片言可以折獄者其由也與子路無宿諾\n",
      "子曰聽訟吾猶人也必也使無訟乎\n",
      "子張問政子曰居之無倦行之以忠\n",
      "子曰君子博學於文約之以禮亦可以弗畔矣夫\n",
      "子曰君子成人之美不成人之惡小人反是\n",
      "季康子問政於孔子孔子對曰政者正也子帥以正孰敢不正\n",
      "季康子患盜問於孔子孔子對曰苟子之不欲雖賞之不竊\n",
      "季康子問政於孔子曰如殺無道以就有道何如孔子對曰子為政焉用殺子欲善而民善矣君子之德風小人之德草草上之風必偃\n",
      "子張問士何如斯可謂之達矣子曰何哉爾所謂達者子張對曰在邦必聞在家必聞子曰是聞也非達也夫達也者質直而好義察言而觀色慮以下人在邦必達在家必達夫聞也者色取仁而行違居之不疑在邦必聞在家必聞\n",
      "樊遲從遊於舞雩之下曰敢問崇德脩慝辨惑子曰善哉問先事後得非崇德與攻其惡無攻人之惡非脩慝與一朝之忿忘其身以及其親非惑與\n",
      "樊遲問仁子曰愛人問知子曰知人樊遲未達子曰舉直錯諸枉能使枉者直樊遲退見子夏曰鄉也吾見於夫子而問知子曰舉直錯諸枉能使枉者直何謂也子夏曰富哉言乎舜有天下選於眾舉皋陶不仁者遠矣湯有天下選於眾舉伊尹不仁者遠矣\n",
      "子貢問友子曰忠告而善道之不可則止無自辱焉\n",
      "曾子曰君子以文會友以友輔仁\n",
      "子路問政子曰先之勞之請益曰無倦\n",
      "仲弓為季氏宰問政子曰先有司赦小過舉賢才曰焉知賢才而舉之曰舉爾所知爾所不知人其舍諸\n",
      "子路曰衛君待子而為政子將奚先子曰必也正名乎子路曰有是哉子之迂也奚其正子曰野哉由也君子於其所不知蓋闕如也名不正則言不順言不順則事不成事不成則禮樂不興禮樂不興則刑罰不中刑罰不中則民無所措手足故君子名之必可言也言之必可行也君子於其言無所苟而已矣\n",
      "樊遲請學稼子曰吾不如老農請學為圃曰吾不如老圃樊遲出子曰小人哉樊須也上好禮則民莫敢不敬上好義則民莫敢不服上好信則民莫敢不用情夫如是則四方之民襁負其子而至矣焉用稼\n",
      "子曰誦詩三百授之以政不達使於四方不能專對雖多亦奚以為\n",
      "子曰其身正不令而行其身不正雖令不從\n",
      "子曰魯衛之政兄弟也\n",
      "子謂衛公子荊善居室始有曰苟合矣少有曰苟完矣富有曰苟美矣\n",
      "子適衛冉有僕子曰庶矣哉冉有曰既庶矣又何加焉曰富之曰既富矣又何加焉曰教之\n",
      "子曰苟有用我者期月而已可也三年有成\n",
      "子曰善人為邦百年亦可以勝殘去殺矣誠哉是言也\n",
      "子曰如有王者必世而後仁\n",
      "子曰苟正其身矣於從政乎何有不能正其身如正人何\n",
      "冉子退朝子曰何晏也對曰有政子曰其事也如有政雖不吾以吾其與聞之\n",
      "定公問一言而可以興邦有諸孔子對曰言不可以若是其幾也人之言曰為君難為臣不易如知為君之難也不幾乎一言而興邦乎曰一言而喪邦有諸孔子對曰言不可以若是其幾也人之言曰予無樂乎為君唯其言而莫予違也如其善而莫之違也不亦善乎如不善而莫之違也不幾乎一言而喪邦乎\n",
      "葉公問政子曰近者說遠者來\n",
      "子夏為莒父宰問政子曰無欲速無見小利欲速則不達見小利則大事不成\n",
      "葉公語孔子曰吾黨有直躬者其父攘羊而子證之孔子曰吾黨之直者異於是父為子隱子為父隱直在其中矣\n",
      "樊遲問仁子曰居處恭執事敬與人忠雖之夷狄不可棄也\n",
      "子貢問曰何如斯可謂之士矣子曰行己有恥使於四方不辱君命可謂士矣曰敢問其次曰宗族稱孝焉鄉黨稱弟焉曰敢問其次曰言必信行必果硜硜然小人哉抑亦可以為次矣曰今之從政者何如子曰噫斗筲之人何足算也\n",
      "子曰不得中行而與之必也狂狷乎狂者進取狷者有所不為也\n",
      "子曰南人有言曰人而無恆不可以作巫醫善夫不恆其德或承之羞子曰不占而已矣\n",
      "子曰君子和而不同小人同而不和\n",
      "子貢問曰鄉人皆好之何如子曰未可也鄉人皆惡之何如子曰未可也不如鄉人之善者好之其不善者惡之\n",
      "子曰君子易事而難說也說之不以道不說也及其使人也器之小人難事而易說也說之雖不以道說也及其使人也求備焉\n",
      "子曰君子泰而不驕小人驕而不泰\n",
      "子曰剛毅木訥近仁\n",
      "子路問曰何如斯可謂之士矣子曰切切偲偲怡怡如也可謂士矣朋友切切偲偲兄弟怡怡\n",
      "子曰善人教民七年亦可以即戎矣\n",
      "子曰以不教民戰是謂棄之\n",
      "憲問恥子曰邦有道穀邦無道穀恥也克伐怨欲不行焉可以為仁矣子曰可以為難矣仁則吾不知也\n",
      "子曰士而懷居不足以為士矣\n",
      "子曰邦有道危言危行邦無道危行言孫\n",
      "子曰有德者必有言有言者不必有德仁者必有勇勇者不必有仁\n",
      "南宮适問於孔子曰羿善射奡盪舟俱不得其死然禹稷躬稼而有天下夫子不答南宮适出子曰君子哉若人尚德哉若人\n",
      "子曰君子而不仁者有矣夫未有小人而仁者也\n",
      "子曰愛之能勿勞乎忠焉能勿誨乎\n",
      "子曰為命裨諶草創之世叔討論之行人子羽脩飾之東里子產潤色之\n",
      "或問子產子曰惠人也問子西曰彼哉彼哉問管仲曰人也奪伯氏駢邑三百飯疏食沒齒無怨言\n",
      "子曰貧而無怨難富而無驕易\n",
      "子曰孟公綽為趙魏老則優不可以為滕薛大夫\n",
      "子路問成人子曰若臧武仲之知公綽之不欲卞莊子之勇冉求之藝文之以禮樂亦可以為成人矣曰今之成人者何必然見利思義見危授命久要不忘平生之言亦可以為成人矣\n",
      "子問公叔文子於公明賈曰信乎夫子不言不笑不取乎公明賈對曰以告者過也夫子時然後言人不厭其言樂然後笑人不厭其笑義然後取人不厭其取子曰其然豈其然乎\n",
      "子曰臧武仲以防求為後於魯雖曰不要君吾不信也\n",
      "子曰晉文公譎而不正齊桓公正而不譎\n",
      "子路曰桓公殺公子糾召忽死之管仲不死曰未仁乎子曰桓公九合諸侯不以兵車管仲之力也如其仁如其仁\n",
      "子貢曰管仲非仁者與桓公殺公子糾不能死又相之子曰管仲相桓公霸諸侯一匡天下民到于今受其賜微管仲吾其被髮左衽矣豈若匹夫匹婦之為諒也自經於溝瀆而莫之知也\n",
      "公叔文子之臣大夫僎與文子同升諸公子聞之曰可以為文矣\n",
      "子言衛靈公之無道也康子曰夫如是奚而不喪孔子曰仲叔圉治賓客祝鮀治宗廟王孫賈治軍旅夫如是奚其喪\n",
      "子曰其言之不怍則為之也難\n",
      "陳成子弒簡公孔子沐浴而朝告於哀公曰陳恆弒其君請討之公曰告夫三子孔子曰以吾從大夫之後不敢不告也君曰告夫三子者之三子告不可孔子曰以吾從大夫之後不敢不告也\n",
      "子路問事君子曰勿欺也而犯之\n",
      "子曰君子上達小人下達\n",
      "子曰古之學者為己今之學者為人\n",
      "蘧伯玉使人於孔子孔子與之坐而問焉曰夫子何為對曰夫子欲寡其過而未能也使者出子曰使乎使乎\n",
      "子曰不在其位不謀其政曾子曰君子思不出其位\n",
      "子曰君子恥其言而過其行\n",
      "子曰君子道者三我無能焉仁者不憂知者不惑勇者不懼子貢曰夫子自道也\n",
      "子貢方人子曰賜也賢乎哉夫我則不暇\n",
      "子曰不患人之不己知患其不能也\n",
      "子曰不逆詐不億不信抑亦先覺者是賢乎\n",
      "微生畝謂孔子曰丘何為是栖栖者與無乃為佞乎孔子曰非敢為佞也疾固也\n",
      "子曰驥不稱其力稱其德也\n",
      "或曰以德報怨何如子曰何以報德以直報怨以德報德\n",
      "子曰莫我知也夫子貢曰何為其莫知子也子曰不怨天不尤人下學而上達知我者其天乎\n",
      "公伯寮愬子路於季孫子服景伯以告曰夫子固有惑志於公伯寮吾力猶能肆諸市朝子曰道之將行也與命也道之將廢也與命也公伯寮其如命何\n",
      "子曰賢者辟世其次辟地其次辟色其次辟言子曰作者七人矣\n",
      "子路宿於石門晨門曰奚自子路曰自孔氏曰是知其不可而為之者與\n",
      "子擊磬於衛有荷蕢而過孔氏之門者曰有心哉擊磬乎既而曰鄙哉硜硜乎莫己知也斯己而已矣深則厲淺則揭子曰果哉末之難矣\n",
      "子張曰書云高宗諒陰三年不言何謂也子曰何必高宗古之人皆然君薨百官總己以聽於冢宰三年\n",
      "子曰上好禮則民易使也\n",
      "子路問君子子曰脩己以敬曰如斯而已乎曰脩己以安人曰如斯而已乎曰脩己以安百姓脩己以安百姓堯舜其猶病諸\n",
      "原壤夷俟子曰幼而不孫弟長而無述焉老而不死是為賊以杖叩其脛\n",
      "闕黨童子將命或問之曰益者與子曰吾見其居於位也見其與先生並行也非求益者也欲速成者也\n",
      "衛靈公問陳於孔子孔子對曰俎豆之事則嘗聞之矣軍旅之事未之學也明日遂行\n",
      "在陳絕糧從者病莫能興子路慍見曰君子亦有窮乎子曰君子固窮小人窮斯濫矣\n",
      "子曰賜也女以予為多學而識之者與對曰然非與曰非也予一以貫之\n",
      "子曰由知德者鮮矣\n",
      "子曰無為而治者其舜也與夫何為哉恭己正南面而已矣\n",
      "子張問行子曰言忠信行篤敬雖蠻貊之邦行矣言不忠信行不篤敬雖州里行乎哉立則見其參於前也在輿則見其倚於衡也夫然後行子張書諸紳\n",
      "子曰直哉史魚邦有道如矢邦無道如矢君子哉蘧伯玉邦有道則仕邦無道則可卷而懷之\n",
      "子曰可與言而不與之言失人不可與言而與之言失言知者不失人亦不失言\n",
      "子曰志士仁人無求生以害仁有殺身以成仁\n",
      "子貢問為仁子曰工欲善其事必先利其器居是邦也事其大夫之賢者友其士之仁者\n",
      "顏淵問為邦子曰行夏之時乘殷之輅服周之冕樂則韶舞放鄭聲遠佞人鄭聲淫佞人殆\n",
      "子曰人無遠慮必有近憂\n",
      "子曰已矣乎吾未見好德如好色者也\n",
      "子曰臧文仲其竊位者與知柳下惠之賢而不與立也\n",
      "子曰躬自厚而薄責於人則遠怨矣\n",
      "子曰不曰如之何如之何者吾末如之何也已矣\n",
      "子曰群居終日言不及義好行小慧難矣哉\n",
      "子曰君子義以為質禮以行之孫以出之信以成之君子哉\n",
      "子曰君子病無能焉不病人之不己知也\n",
      "子曰君子疾沒世而名不稱焉\n",
      "子曰君子求諸己小人求諸人\n",
      "子曰君子矜而不爭群而不黨\n",
      "子曰君子不以言舉人不以人廢言\n",
      "子貢問曰有一言而可以終身行之者乎子曰其恕乎己所不欲勿施於人\n",
      "子曰吾之於人也誰毀誰譽如有所譽者其有所試矣斯民也三代之所以直道而行也\n",
      "子曰吾猶及史之闕文也有馬者借人乘之今亡矣夫\n",
      "子曰巧言亂德小不忍則亂大謀\n",
      "子曰眾惡之必察焉眾好之必察焉\n",
      "子曰人能弘道非道弘人\n",
      "子曰過而不改是謂過矣\n",
      "子曰吾嘗終日不食終夜不寢以思無益不如學也\n",
      "子曰君子謀道不謀食耕也餒在其中矣學也祿在其中矣君子憂道不憂貧\n",
      "子曰知及之仁不能守之雖得之必失之知及之仁能守之不莊以涖之則民不敬知及之仁能守之莊以涖之動之不以禮未善也\n",
      "子曰君子不可小知而可大受也小人不可大受而可小知也\n",
      "子曰民之於仁也甚於水火水火吾見蹈而死者矣未見蹈仁而死者也\n",
      "子曰當仁不讓於師\n",
      "子曰君子貞而不諒\n",
      "子曰事君敬其事而後其食\n",
      "子曰有教無類\n",
      "子曰道不同不相為謀\n",
      "子曰辭達而已矣\n",
      "師冕見及階子曰階也及席子曰席也皆坐子告之曰某在斯某在斯師冕出子張問曰與師言之道與子曰然固相師之道也\n",
      "季氏將伐顓臾冉有季路見於孔子曰季氏將有事於顓臾孔子曰求無乃爾是過與夫顓臾昔者先王以為東蒙主且在邦域之中矣是社稷之臣也何以伐為冉有曰夫子欲之吾二臣者皆不欲也孔子曰求周任有言曰陳力就列不能者止危而不持顛而不扶則將焉用彼相矣且爾言過矣虎兕出於柙龜玉毀於櫝中是誰之過與冉有曰今夫顓臾固而近於費今不取後世必為子孫憂孔子曰求君子疾夫舍曰欲之而必為之辭丘也聞有國有家者不患寡而患不均不患貧而患不安蓋均無貧和無寡安無傾夫如是故遠人不服則修文德以來之既來之則安之今由與求也相夫子遠人不服而不能來也邦分崩離析而不能守也而謀動干戈於邦內吾恐季孫之憂不在顓臾而在蕭牆之內也\n",
      "孔子曰天下有道則禮樂征伐自天子出天下無道則禮樂征伐自諸侯出自諸侯出蓋十世希不失矣自大夫出五世希不失矣陪臣執國命三世希不失矣天下有道則政不在大夫天下有道則庶人不議\n",
      "孔子曰祿之去公室五世矣政逮於大夫四世矣故夫三桓之子孫微矣\n",
      "孔子曰益者三友損者三友友直友諒友多聞益矣友便辟友善柔友便佞損矣\n",
      "孔子曰益者三樂損者三樂樂節禮樂樂道人之善樂多賢友益矣樂驕樂樂佚遊樂宴樂損矣\n",
      "孔子曰侍於君子有三愆言未及之而言謂之躁言及之而不言謂之隱未見顏色而言謂之瞽\n",
      "孔子曰君子有三戒少之時血氣未定戒之在色及其壯也血氣方剛戒之在鬭及其老也血氣既衰戒之在得\n",
      "孔子曰君子有三畏畏天命畏大人畏聖人之言小人不知天命而不畏也狎大人侮聖人之言\n",
      "孔子曰生而知之者上也學而知之者次也困而學之又其次也困而不學民斯為下矣\n",
      "孔子曰君子有九思視思明聽思聰色思溫貌思恭言思忠事思敬疑思問忿思難見得思義\n",
      "孔子曰見善如不及見不善如探湯吾見其人矣吾聞其語矣隱居以求其志行義以達其道吾聞其語矣未見其人也\n",
      "齊景公有馬千駟死之日民無德而稱焉伯夷叔齊餓于首陽之下民到于今稱之其斯之謂與\n",
      "陳亢問於伯魚曰子亦有異聞乎對曰未也嘗獨立鯉趨而過庭曰學詩乎對曰未也不學詩無以言鯉退而學詩他日又獨立鯉趨而過庭曰學禮乎對曰未也不學禮無以立鯉退而學禮聞斯二者陳亢退而喜曰問一得三聞詩聞禮又聞君子之遠其子也\n",
      "邦君之妻君稱之曰夫人夫人自稱曰小童邦人稱之曰君夫人稱諸異邦曰寡小君異邦人稱之亦曰君夫人\n",
      "陽貨欲見孔子孔子不見歸孔子豚孔子時其亡也而往拜之遇諸塗謂孔子曰來予與爾言曰懷其寶而迷其邦可謂仁乎曰不可好從事而亟失時可謂知乎曰不可日月逝矣歲不我與孔子曰諾吾將仕矣\n",
      "子曰性相近也習相遠也\n",
      "子曰唯上知與下愚不移\n",
      "子之武城聞弦歌之聲夫子莞爾而笑曰割雞焉用牛刀子游對曰昔者偃也聞諸夫子曰君子學道則愛人小人學道則易使也子曰二三子偃之言是也前言戲之耳\n",
      "公山弗擾以費畔召子欲往子路不說曰末之也已何必公山氏之之也子曰夫召我者而豈徒哉如有用我者吾其為東周乎\n",
      "子張問仁於孔子孔子曰能行五者於天下為仁矣請問之曰恭寬信敏惠恭則不侮寬則得眾信則人任焉敏則有功惠則足以使人\n",
      "佛肸召子欲往子路曰昔者由也聞諸夫子曰親於其身為不善者君子不入也佛肸以中牟畔子之往也如之何子曰然有是言也不曰堅乎磨而不磷不曰白乎涅而不緇吾豈匏瓜也哉焉能繫而不食\n",
      "子曰由也女聞六言六蔽矣乎對曰未也居吾語女好仁不好學其蔽也愚好知不好學其蔽也蕩好信不好學其蔽也賊好直不好學其蔽也絞好勇不好學其蔽也亂好剛不好學其蔽也狂\n",
      "子曰小子何莫學夫詩詩可以興可以觀可以群可以怨邇之事父遠之事君多識於鳥獸草木之名\n",
      "子謂伯魚曰女為周南召南矣乎人而不為周南召南其猶正牆面而立也與\n",
      "子曰禮云禮云玉帛云乎哉樂云樂云鐘鼓云乎哉\n",
      "子曰色厲而內荏譬諸小人其猶穿窬之盜也與\n",
      "子曰鄉原德之賊也\n",
      "子曰道聽而塗說德之棄也\n",
      "子曰鄙夫可與事君也與哉其未得之也患得之既得之患失之苟患失之無所不至矣\n",
      "子曰古者民有三疾今也或是之亡也古之狂也肆今之狂也蕩古之矜也廉今之矜也忿戾古之愚也直今之愚也詐而已矣\n",
      "子曰巧言令色鮮矣仁\n",
      "子曰惡紫之奪朱也惡鄭聲之亂雅樂也惡利口之覆邦家者\n",
      "子曰予欲無言子貢曰子如不言則小子何述焉子曰天何言哉四時行焉百物生焉天何言哉\n",
      "孺悲欲見孔子孔子辭以疾將命者出戶取瑟而歌使之聞之\n",
      "宰我問三年之喪期已久矣君子三年不為禮禮必壞三年不為樂樂必崩舊穀既沒新穀既升鑽燧改火期可已矣子曰食夫稻衣夫錦於女安乎曰安女安則為之夫君子之居喪食旨不甘聞樂不樂居處不安故不為也今女安則為之宰我出子曰予之不仁也子生三年然後免於父母之懷夫三年之喪天下之通喪也予也有三年之愛於其父母乎\n",
      "子曰飽食終日無所用心難矣哉不有博弈者乎為之猶賢乎已\n",
      "子路曰君子尚勇乎子曰君子義以為上君子有勇而無義為亂小人有勇而無義為盜\n",
      "子貢曰君子亦有惡乎子曰有惡惡稱人之惡者惡居下流而訕上者惡勇而無禮者惡果敢而窒者曰賜也亦有惡乎惡徼以為知者惡不孫以為勇者惡訐以為直者\n",
      "子曰唯女子與小人為難養也近之則不孫遠之則怨\n",
      "子曰年四十而見惡焉其終也已\n",
      "微子去之箕子為之奴比干諫而死孔子曰殷有三仁焉\n",
      "柳下惠為士師三黜人曰子未可以去乎曰直道而事人焉往而不三黜枉道而事人何必去父母之邦\n",
      "齊景公待孔子曰若季氏則吾不能以季孟之閒待之曰吾老矣不能用也孔子行\n",
      "齊人歸女樂季桓子受之三日不朝孔子行\n",
      "楚狂接輿歌而過孔子曰鳳兮鳳兮何德之衰往者不可諫來者猶可追已而已而今之從政者殆而孔子下欲與之言趨而辟之不得與之言\n",
      "長沮桀溺耦而耕孔子過之使子路問津焉長沮曰夫執輿者為誰子路曰為孔丘曰是魯孔丘與曰是也曰是知津矣問於桀溺桀溺曰子為誰曰為仲由曰是魯孔丘之徒與對曰然曰滔滔者天下皆是也而誰以易之且而與其從辟人之士也豈若從辟世之士哉耰而不輟子路行以告夫子憮然曰鳥獸不可與同群吾非斯人之徒與而誰與天下有道丘不與易也\n",
      "子路從而後遇丈人以杖荷蓧子路問曰子見夫子乎丈人曰四體不勤五穀不分孰為夫子植其杖而芸子路拱而立止子路宿殺雞為黍而食之見其二子焉明日子路行以告子曰隱者也使子路反見之至則行矣子路曰不仕無義長幼之節不可廢也君臣之義如之何其廢之欲潔其身而亂大倫君子之仕也行其義也道之不行已知之矣\n",
      "逸民伯夷叔齊虞仲夷逸朱張柳下惠少連子曰不降其志不辱其身伯夷叔齊與謂柳下惠少連降志辱身矣言中倫行中慮其斯而已矣謂虞仲夷逸隱居放言身中清廢中權我則異於是無可無不可\n",
      "大師摯適齊亞飯干適楚三飯繚適蔡四飯缺適秦鼓方叔入於河播鼗武入於漢少師陽擊磬襄入於海\n",
      "周公謂魯公曰君子不施其親不使大臣怨乎不以故舊無大故則不棄也無求備於一人\n",
      "周有八士伯達伯適仲突仲忽叔夜叔夏季隨季騧\n",
      "子張曰士見危致命見得思義祭思敬喪思哀其可已矣\n",
      "子張曰執德不弘信道不篤焉能為有焉能為亡\n",
      "子夏之門人問交於子張子張曰子夏云何對曰子夏曰可者與之其不可者拒之子張曰異乎吾所聞君子尊賢而容眾嘉善而矜不能我之大賢與於人何所不容我之不賢與人將拒我如之何其拒人也\n",
      "子夏曰雖小道必有可觀者焉致遠恐泥是以君子不為也\n",
      "子夏曰日知其所亡月無忘其所能可謂好學也已矣\n",
      "子夏曰博學而篤志切問而近思仁在其中矣\n",
      "子夏曰百工居肆以成其事君子學以致其道\n",
      "子夏曰小人之過也必文\n",
      "子夏曰君子有三變望之儼然即之也溫聽其言也厲\n",
      "子夏曰君子信而後勞其民未信則以為厲己也信而後諫未信則以為謗己也\n",
      "子夏曰大德不踰閑小德出入可也\n",
      "子游曰子夏之門人小子當洒掃應對進退則可矣抑末也本之則無如之何子夏聞之曰噫言游過矣君子之道孰先傳焉孰後倦焉譬諸草木區以別矣君子之道焉可誣也有始有卒者其惟聖人乎\n",
      "子夏曰仕而優則學學而優則仕\n",
      "子游曰喪致乎哀而止\n",
      "子游曰吾友張也為難能也然而未仁\n",
      "曾子曰堂堂乎張也難與並為仁矣\n",
      "曾子曰吾聞諸夫子人未有自致者也必也親喪乎\n",
      "曾子曰吾聞諸夫子孟莊子之孝也其他可能也其不改父之臣與父之政是難能也\n",
      "孟氏使陽膚為士師問於曾子曾子曰上失其道民散久矣如得其情則哀矜而勿喜\n",
      "子貢曰紂之不善不如是之甚也是以君子惡居下流天下之惡皆歸焉\n",
      "子貢曰君子之過也如日月之食焉過也人皆見之更也人皆仰之\n",
      "衛公孫朝問於子貢曰仲尼焉學子貢曰文武之道未墜於地在人賢者識其大者不賢者識其小者莫不有文武之道焉夫子焉不學而亦何常師之有\n",
      "叔孫武叔語大夫於朝曰子貢賢於仲尼子服景伯以告子貢子貢曰譬之宮牆賜之牆也及肩窺見室家之好夫子之牆數仞不得其門而入不見宗廟之美百官之富得其門者或寡矣夫子之云不亦宜乎\n",
      "叔孫武叔毀仲尼子貢曰無以為也仲尼不可毀也他人之賢者丘陵也猶可踰也仲尼日月也無得而踰焉人雖欲自絕其何傷於日月乎多見其不知量也\n",
      "陳子禽謂子貢曰子為恭也仲尼豈賢於子乎子貢曰君子一言以為知一言以為不知言不可不慎也夫子之不可及也猶天之不可階而升也夫子之得邦家者所謂立之斯立道之斯行綏之斯來動之斯和其生也榮其死也哀如之何其可及也\n",
      "堯曰咨爾舜天之曆數在爾躬允執其中四海困窮天祿永終舜亦以命禹曰予小子履敢用玄牡敢昭告于皇皇后帝有罪不敢赦帝臣不蔽簡在帝心朕躬有罪無以萬方萬方有罪罪在朕躬周有大賚善人是富雖有周親不如仁人百姓有過在予一人謹權量審法度修廢官四方之政行焉興滅國繼絕世舉逸民天下之民歸心焉所重民食喪祭寬則得眾信則民任焉敏則有功公則說\n",
      "子張問於孔子曰何如斯可以從政矣子曰尊五美屏四惡斯可以從政矣子張曰何謂五美子曰君子惠而不費勞而不怨欲而不貪泰而不驕威而不猛子張曰何謂惠而不費子曰因民之所利而利之斯不亦惠而不費乎擇可勞而勞之又誰怨欲仁而得仁又焉貪君子無眾寡無小大無敢慢斯不亦泰而不驕乎君子正其衣冠尊其瞻視儼然人望而畏之斯不亦威而不猛乎子張曰何謂四惡子曰不教而殺謂之虐不戒視成謂之暴慢令致期謂之賊猶之與人也出納之吝謂之有司\n",
      "子曰不知命無以為君子也不知禮無以立也不知言無以知人也\n"
     ]
    }
   ],
   "source": [
    "for line in analects_df['content']:\n",
    "    raw_char_count(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       32\n",
       "1       48\n",
       "2        9\n",
       "3       28\n",
       "4       20\n",
       "5       27\n",
       "6       38\n",
       "7       27\n",
       "8       12\n",
       "9       53\n",
       "10      24\n",
       "11      38\n",
       "12      28\n",
       "13      31\n",
       "14      64\n",
       "15      14\n",
       "16      18\n",
       "17      14\n",
       "18      27\n",
       "19      40\n",
       "20      49\n",
       "21      14\n",
       "22      28\n",
       "23      27\n",
       "24      25\n",
       "25      22\n",
       "26      12\n",
       "27       6\n",
       "28      15\n",
       "29      14\n",
       "      ... \n",
       "473     35\n",
       "474     20\n",
       "475     22\n",
       "476     19\n",
       "477     80\n",
       "478     23\n",
       "479     21\n",
       "480     18\n",
       "481     18\n",
       "482     10\n",
       "483     21\n",
       "484     31\n",
       "485     14\n",
       "486     78\n",
       "487     13\n",
       "488      9\n",
       "489     15\n",
       "490     14\n",
       "491     20\n",
       "492     33\n",
       "493     33\n",
       "494     28\n",
       "495     26\n",
       "496     59\n",
       "497     80\n",
       "498     61\n",
       "499     96\n",
       "500    152\n",
       "501    191\n",
       "502     26\n",
       "Name: content, Length: 503, dtype: int64"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df['content'].apply(raw_char_count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       41\n",
       "1       61\n",
       "2       14\n",
       "3       35\n",
       "4       27\n",
       "5       37\n",
       "6       47\n",
       "7       35\n",
       "8       17\n",
       "9       70\n",
       "10      33\n",
       "11      49\n",
       "12      37\n",
       "13      39\n",
       "14      93\n",
       "15      19\n",
       "16      24\n",
       "17      22\n",
       "18      36\n",
       "19      50\n",
       "20      72\n",
       "21      19\n",
       "22      38\n",
       "23      35\n",
       "24      34\n",
       "25      30\n",
       "26      17\n",
       "27      10\n",
       "28      21\n",
       "29      19\n",
       "      ... \n",
       "473     43\n",
       "474     29\n",
       "475     30\n",
       "476     26\n",
       "477    104\n",
       "478     30\n",
       "479     27\n",
       "480     24\n",
       "481     23\n",
       "482     14\n",
       "483     28\n",
       "484     38\n",
       "485     19\n",
       "486    103\n",
       "487     18\n",
       "488     13\n",
       "489     21\n",
       "490     19\n",
       "491     26\n",
       "492     42\n",
       "493     42\n",
       "494     35\n",
       "495     35\n",
       "496     74\n",
       "497     99\n",
       "498     76\n",
       "499    117\n",
       "500    200\n",
       "501    247\n",
       "502     35\n",
       "Name: content, Length: 503, dtype: int64"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df['content'].apply(char_count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         [子曰, 學而時習之, 不亦說乎, 有朋自遠方來, 不亦樂乎, 人不知而不慍, 不亦君子乎]\n",
       "1      [有子曰, 其為人也孝弟, 而好犯上者, 鮮矣, 不好犯上, 而好作亂者, 未之有也, 君子...\n",
       "2                                        [子曰, 巧言令色, 鮮矣仁]\n",
       "3                 [曾子曰, 吾日三省吾身, 為人謀而不忠乎, 與朋友交而不信乎, 傳不習乎]\n",
       "4                         [子曰, 道千乘之國, 敬事而信, 節用而愛人, 使民以時]\n",
       "5            [子曰, 弟子入則孝, 出則弟, 謹而信, 汎愛眾, 而親仁, 行有餘力, 則以學文]\n",
       "6      [子夏曰, 賢賢易色, 事父母能竭其力, 事君能致其身, 與朋友交言而有信, 雖曰未學, 吾...\n",
       "7                [子曰, 君子不重則不威, 學則不固, 主忠信, 無友不如己者, 過則勿憚改]\n",
       "8                                     [曾子曰, 慎終追遠, 民德歸厚矣]\n",
       "9      [子禽問於子貢曰, 夫子至於是邦也, 必聞其政, 求之與, 抑與之與, 子貢曰, 夫子溫良恭...\n",
       "10                [子曰, 父在, 觀其志, 父沒, 觀其行, 三年無改於父之道, 可謂孝矣]\n",
       "11     [有子曰, 禮之用, 和為貴, 先王之道斯為美, 小大由之, 有所不行, 知和而和, 不以禮...\n",
       "12            [有子曰, 信近於義, 言可復也, 恭近於禮, 遠恥辱也, 因不失其親, 亦可宗也]\n",
       "13           [子曰, 君子食無求飽, 居無求安, 敏於事而慎於言, 就有道而正焉, 可謂好學也已]\n",
       "14     [子貢曰, 貧而無諂, 富而無驕, 何如, 子曰, 可也, 未若貧而樂, 富而好禮者也, 子...\n",
       "15                                  [子曰, 不患人之不己知, 患不知人也]\n",
       "16                            [子曰, 為政以德, 譬如北辰, 居其所而眾星共之]\n",
       "17                                [子曰, 詩三百, 一言以蔽之, 曰思無邪]\n",
       "18             [子曰, 道之以政, 齊之以刑, 民免而無恥, 道之以德, 齊之以禮, 有恥且格]\n",
       "19     [子曰, 吾十有五而志于學, 三十而立, 四十而不惑, 五十而知天命, 六十而耳順, 七十而...\n",
       "20     [孟懿子問孝, 子曰, 無違, 樊遲御, 子告之曰, 孟孫問孝於我, 我對曰無違, 樊遲曰,...\n",
       "21                                  [孟武伯問孝, 子曰, 父母唯其疾之憂]\n",
       "22          [子游問孝, 子曰, 今之孝者, 是謂能養, 至於犬馬, 皆能有養, 不敬, 何以別乎]\n",
       "23               [子夏問孝, 子曰, 色難, 有事弟子服其勞, 有酒食先生饌, 曾是以為孝乎]\n",
       "24               [子曰, 吾與回言終日, 不違如愚, 退而省其私, 亦足以發, 回也, 不愚]\n",
       "25                    [子曰, 視其所以, 觀其所由, 察其所安, 人焉廋哉, 人焉廋哉]\n",
       "26                                    [子曰, 溫故而知新, 可以為師矣]\n",
       "27                                            [子曰, 君子不器]\n",
       "28                               [子貢問君子, 子曰, 先行其言, 而後從之]\n",
       "29                                  [子曰, 君子周而不比, 小人比而不周]\n",
       "                             ...                        \n",
       "473      [周公謂魯公曰, 君子不施其親, 不使大臣怨乎不以, 故舊無大故, 則不棄也, 無求備於一人]\n",
       "474                             [周有八士, 伯達伯適仲突仲忽叔夜叔夏季隨季騧]\n",
       "475                   [子張曰, 士見危致命, 見得思義, 祭思敬, 喪思哀, 其可已矣]\n",
       "476                        [子張曰, 執德不弘, 信道不篤, 焉能為有, 焉能為亡]\n",
       "477    [子夏之門人問交於子張, 子張曰, 子夏云何, 對曰, 子夏曰, 可者與之, 其不可者拒之,...\n",
       "478                    [子夏曰, 雖小道, 必有可觀者焉, 致遠恐泥, 是以君子不為也]\n",
       "479                        [子夏曰, 日知其所亡, 月無忘其所能, 可謂好學也已矣]\n",
       "480                           [子夏曰, 博學而篤志, 切問而近思, 仁在其中矣]\n",
       "481                             [子夏曰, 百工居肆以成其事, 君子學以致其道]\n",
       "482                                       [子夏曰, 小人之過也必文]\n",
       "483                      [子夏曰, 君子有三變, 望之儼然, 即之也溫, 聽其言也厲]\n",
       "484            [子夏曰, 君子信而後勞其民, 未信則以為厲己也, 信而後諫, 未信則以為謗己也]\n",
       "485                                 [子夏曰, 大德不踰閑, 小德出入可也]\n",
       "486    [子游曰, 子夏之門人小子, 當洒掃應對進退, 則可矣, 抑末也, 本之則無, 如之何, 子...\n",
       "487                                  [子夏曰, 仕而優則學, 學而優則仕]\n",
       "488                                        [子游曰, 喪致乎哀而止]\n",
       "489                              [子游曰, 吾友張也, 為難能也, 然而未仁]\n",
       "490                                 [曾子曰, 堂堂乎張也, 難與並為仁矣]\n",
       "491                         [曾子曰, 吾聞諸夫子, 人未有自致者也, 必也親喪乎]\n",
       "492      [曾子曰, 吾聞諸夫子, 孟莊子之孝也, 其他可能也, 其不改父之臣, 與父之政, 是難能也]\n",
       "493      [孟氏使陽膚為士師, 問於曾子, 曾子曰, 上失其道, 民散久矣, 如得其情, 則哀矜而勿喜]\n",
       "494               [子貢曰, 紂之不善, 不如是之甚也, 是以君子惡居下流, 天下之惡皆歸焉]\n",
       "495             [子貢曰, 君子之過也, 如日月之食焉, 過也, 人皆見之, 更也, 人皆仰之]\n",
       "496    [衛公孫朝問於子貢曰, 仲尼焉學, 子貢曰, 文武之道, 未墜於地, 在人, 賢者識其大者,...\n",
       "497    [叔孫武叔語大夫於朝, 曰, 子貢賢於仲尼, 子服景伯以告子貢, 子貢曰, 譬之宮牆, 賜之...\n",
       "498    [叔孫武叔毀仲尼, 子貢曰, 無以為也, 仲尼不可毀也, 他人之賢者, 丘陵也, 猶可踰也,...\n",
       "499    [陳子禽謂子貢曰, 子為恭也, 仲尼豈賢於子乎, 子貢曰, 君子一言以為知, 一言以為不知,...\n",
       "500    [堯曰, 咨爾舜天之曆數在爾躬, 允執其中, 四海困窮, 天祿永終, 舜亦以命禹, 曰, 予...\n",
       "501    [子張問於孔子曰, 何如斯可以從政矣, 子曰, 尊五美, 屏四惡, 斯可以從政矣, 子張曰,...\n",
       "502             [子曰, 不知命, 無以為君子也, 不知禮, 無以立也, 不知言, 無以知人也]\n",
       "Name: content, Length: 503, dtype: object"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analects_df['content'].apply(get_sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
